package com.soonfor.evaluate.view;

import android.app.Activity;
import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;


import butterknife.BindView;
import butterknife.ButterKnife;
import com.estronger.shopmanage.R;
import com.soonfor.evaluate.bean.EvaluateRankingBean;

/**
 * 作者：DC-DingYG on 2018-10-17 13:57
 * 邮箱：dingyg012655@126.com
 */
public class ClientEvalToMeView extends LinearLayout {
    private Context mContext;
    @BindView(R.id.tv_good_evaluation_amount)
    TextView tvfGood;//
    @BindView(R.id.tv_general_evaluation_amount)
    TextView tvfMedium;//
    @BindView(R.id.tv_bad_evaluation_amount)
    TextView tvfBad;//
    @BindView(R.id.rPGood)
    RingProgressView rpGood;
    @BindView(R.id.tvfGoodValue)
    TextView tvfGoodValue;
    @BindView(R.id.rPReVisit)
    RingProgressView rpReVisit;
    @BindView(R.id.tvfReVisitValue)
    TextView tvfReVisitValue;
    @BindView(R.id.ll_more_wvaluation)
    LinearLayout ll_more_wvaluation;//更多评价

    public ClientEvalToMeView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        View view = View.inflate(context, R.layout.me_evaluation_layout, this);
        ButterKnife.bind(this, view);
    }

    //初始化
    public void initEvalToMeView(final Activity mContext, final EvaluateRankingBean bean) {
        this.mContext = mContext;
        if(bean!=null) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    mContext.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            try {
                                tvfGood.setText(bean.getFallhighappraiseresultnum1());
                                tvfMedium.setText(bean.getFallhighappraiseresultnum2());
                                tvfBad.setText(bean.getFallhighappraiseresultnum3());
                                rpGood.setPercent(Float.parseFloat(bean.getFallhighappraiserate()));
                                rpGood.showProgress();

                                tvfGoodValue.setText(bean.getFallhighappraiserate() + "%");
                                rpReVisit.setPercent(Float.parseFloat(bean.getFavgrtnvisitpoint()));
                                rpReVisit.showProgress();
                                tvfReVisitValue.setText(bean.getFavgrtnvisitpoint());
                            }catch (Exception e){}
                        }
                    });
                }
            }).start();
        }
    }
    public void IsHasMore(boolean isHas){
        if(isHas){
            ll_more_wvaluation.setVisibility(VISIBLE);
        }else {
            ll_more_wvaluation.setVisibility(GONE);
        }
    }
}
